package javabase.collection.list.listsort;

import java.text.Collator;
import java.text.ParseException;
import java.text.RuleBasedCollator;
import java.util.Arrays;
import java.util.Locale;

/**
 * <pre>
 *   Title: ListSortDemo001.java
 *   Description: 
 *   Copyright: yundaex.com Copyright (c) 2013
 *   Company: 上海韵达货运有限公司
 * </pre>
 * 
 * @author liuzhaoqing
 * @version 1.0
 * @date 2014年11月5日
 */

public class RuleBasedCollatorDemo001 {

	public static void main(String[] args) {
		String [] strArray = new String [] {"路", "人", "甲","]", "?", "鋶", "谧", "儬", 
			"qq", "www", "zzzz", "aaaa"};
		Arrays.sort(strArray, (RuleBasedCollator)Collator.getInstance(Locale.CHINA));
		for (String str : strArray) {
			System.out.println(str);
		}
		System.out.println("------------------------");
		String myRules = "<鋶<儬<谧";
		try {
			RuleBasedCollator rule = new RuleBasedCollator(myRules);
			Arrays.sort(strArray, 7, 10, rule);
			for (String str : strArray) {
				System.out.println(str);
			}
		} catch (ParseException e) {
			e.printStackTrace();
		}
		
	}

}
